﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Projet
{
    
    public class CurrentUser
    {
        MaBaseDataContext bdd = new MaBaseDataContext();
        public int id { get; set; }
        public string name { get; set; }
        public string surname { get; set; }
        public string campus { get; set; }
        public int classe { get; set; }
        public int privilege { get; set; }
        public string cursus { get; set; }

        public bool FillUserInfos(int id) // pour l'utilisateur en cours
        {
            try
            {
                var c = (from p in bdd.Users
                            where p.id == id
                            select p).First();
         
                this.id = c.id;
                this.name = c.name;
                this.surname = c.firstname;
                this.campus = c.campus;
                this.cursus = c.cursus;
                this.classe = (int)c.classe;
                this.privilege = (int)c.privilege;
                return true;
            }
                catch { return false; }

        }
    }
}
